package com.csstu.tomcat.servlet;

import com.csstu.tomcat.http.CsRequest;
import com.csstu.tomcat.http.CsResponse;

import java.io.IOException;

/**
 * @program: cstomcat
 * @description: 程硕httpServlet
 * @author: 程硕
 * @create: 2025-08-16 18:02
 **/
public abstract class CsHttpServlet implements CsServlet {
    @Override
    public void service(CsRequest request, CsResponse response) throws IOException {
        if ("GET".equalsIgnoreCase(request.getMethod())) {
            this.doGet(request,response);
        } else if ("POST".equalsIgnoreCase(request.getMethod())) {
            this.doPost(request,response);
        }

    }
    /*
    * 使用模板设计模式
    * 让CsHttpServlet 的子类实现
    * */
    public abstract void doGet(CsRequest request, CsResponse response);
    public abstract void doPost(CsRequest request, CsResponse response);
}
